﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading.Tasks;
using Abp.Data;
using Abp.Domain.Entities;
using Abp.EntityFrameworkCore;
using JYJ.AiYard.Database;
using JYJ.AiYard.EntityFrameworkCore.Repositories;
using JYJ.AiYard.StationManagement.TbYardPayNormals;
using Microsoft.EntityFrameworkCore;

namespace JYJ.AiYard.EntityFrameworkCore
{
    public class AiYardDbTable : RepositoryAndSqlHelper<TbYardPayNormalCol, long>, IAiYardDbTable
    {
        public AiYardDbTable(IDbContextProvider<AiYardDbContext> dbContextProvider,IActiveTransactionProvider activeTransactionProvider) : base(dbContextProvider, activeTransactionProvider)
        {

        }

        #region 测试
        //public async Task<TbYardPayNormalCol> QueryTbYardPayNormalCol(long Station_ID)
        //{
        //    TbYardPayNormalCol tb = new TbYardPayNormalCol();
        //    string sql = string.Format("select * from [Tb_YardPayNormal_VML] where [Station_ID]={0}", Station_ID);
        //    using (var command = CreateCommand(sql, CommandType.Text))
        //    {
        //        using (var dataReader = command.ExecuteReader())
        //        {
        //            while (dataReader.Read())
        //            {
        //                tb.Id = Convert.ToInt64(dataReader["Id"]);
        //                tb.Station_ID = Convert.ToInt64(dataReader["Station_ID"]);
        //                tb.CardTypeID = Convert.ToInt32(dataReader["CardTypeID"]);
        //                tb.CardType = dataReader["CardType"].ToString();
        //                tb.Free_Minute = Convert.ToInt32(dataReader["Free_Minute"]);
        //                tb.HighPay = Convert.ToDecimal(dataReader["HighPay"]);
        //                tb.Free_Forever = Convert.ToBoolean(dataReader["Free_Forever"]);
        //                tb.HHourPay = Convert.ToBoolean(dataReader["HHourPay"]);
        //                tb.OverTime = Convert.ToInt32(dataReader["OverTime"]);
        //                tb.CHourValue1 = Convert.ToDecimal(dataReader["1"]);
        //                tb.CHourValue2 = Convert.ToDecimal(dataReader["2"]);
        //                tb.CHourValue3 = Convert.ToDecimal(dataReader["3"]);
        //                tb.CHourValue4 = Convert.ToDecimal(dataReader["4"]);
        //                tb.CHourValue5 = Convert.ToDecimal(dataReader["5"]);
        //                tb.CHourValue6 = Convert.ToDecimal(dataReader["6"]);
        //                tb.CHourValue7 = Convert.ToDecimal(dataReader["7"]);
        //                tb.CHourValue8 = Convert.ToDecimal(dataReader["8"]);
        //                tb.CHourValue9 = Convert.ToDecimal(dataReader["9"]);
        //                tb.CHourValue10 = Convert.ToDecimal(dataReader["10"]);
        //                tb.CHourValue11 = Convert.ToDecimal(dataReader["11"]);
        //                tb.CHourValue12 = Convert.ToDecimal(dataReader["12"]);
        //                tb.CHourValue13 = Convert.ToDecimal(dataReader["13"]);
        //                tb.CHourValue14 = Convert.ToDecimal(dataReader["14"]);
        //                tb.CHourValue15 = Convert.ToDecimal(dataReader["15"]);
        //                tb.CHourValue16 = Convert.ToDecimal(dataReader["16"]);
        //                tb.CHourValue17 = Convert.ToDecimal(dataReader["17"]);
        //                tb.CHourValue18 = Convert.ToDecimal(dataReader["18"]);
        //                tb.CHourValue19 = Convert.ToDecimal(dataReader["19"]);
        //                tb.CHourValue20 = Convert.ToDecimal(dataReader["20"]);
        //                tb.CHourValue21 = Convert.ToDecimal(dataReader["21"]);
        //                tb.CHourValue22 = Convert.ToDecimal(dataReader["22"]);
        //                tb.CHourValue23 = Convert.ToDecimal(dataReader["23"]);
        //                tb.CHourValue24 = Convert.ToDecimal(dataReader["24"]);
        //            }
        //        }
        //    }
        //    return tb;
        //}
        #endregion

        public async Task<List<TbYardPayNormalCol>> QueryTbYardPayNormalList(List<long> Station_ID)
        {
            //throw new NotImplementedException();
            List<TbYardPayNormalCol> tbAll = new List<TbYardPayNormalCol>();
            string sql = string.Format("select * from [Tb_YardPayNormal_VML] where [Station_ID] in ({0})", string.Join(",", Station_ID.ToArray()));
            using (var command = CreateCommand(sql, CommandType.Text))
            {
                using (var dataReader = command.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        TbYardPayNormalCol tb = new TbYardPayNormalCol();
                        tb.Id = Convert.ToInt64(dataReader["Id"]);
                        tb.Station_ID = Convert.ToInt64(dataReader["Station_ID"]);
                        tb.CardTypeID = Convert.ToInt32(dataReader["CardTypeID"]);
                        tb.CardType = dataReader["CardType"].ToString();
                        tb.Free_Minute = Convert.ToInt32(dataReader["Free_Minute"]);
                        tb.HighPay = Convert.ToDecimal(dataReader["HighPay"]);
                        tb.Free_Forever = Convert.ToBoolean(dataReader["Free_Forever"]);
                        tb.HHourPay = Convert.ToBoolean(dataReader["HHourPay"]);
                        tb.OverTime = Convert.ToInt32(dataReader["OverTime"]);
                        tb.CHourValue1 = Convert.ToDecimal(dataReader["1"]);
                        tb.CHourValue2 = Convert.ToDecimal(dataReader["2"]);
                        tb.CHourValue3 = Convert.ToDecimal(dataReader["3"]);
                        tb.CHourValue4 = Convert.ToDecimal(dataReader["4"]);
                        tb.CHourValue5 = Convert.ToDecimal(dataReader["5"]);
                        tb.CHourValue6 = Convert.ToDecimal(dataReader["6"]);
                        tb.CHourValue7 = Convert.ToDecimal(dataReader["7"]);
                        tb.CHourValue8 = Convert.ToDecimal(dataReader["8"]);
                        tb.CHourValue9 = Convert.ToDecimal(dataReader["9"]);
                        tb.CHourValue10 = Convert.ToDecimal(dataReader["10"]);
                        tb.CHourValue11 = Convert.ToDecimal(dataReader["11"]);
                        tb.CHourValue12 = Convert.ToDecimal(dataReader["12"]);
                        tb.CHourValue13 = Convert.ToDecimal(dataReader["13"]);
                        tb.CHourValue14 = Convert.ToDecimal(dataReader["14"]);
                        tb.CHourValue15 = Convert.ToDecimal(dataReader["15"]);
                        tb.CHourValue16 = Convert.ToDecimal(dataReader["16"]);
                        tb.CHourValue17 = Convert.ToDecimal(dataReader["17"]);
                        tb.CHourValue18 = Convert.ToDecimal(dataReader["18"]);
                        tb.CHourValue19 = Convert.ToDecimal(dataReader["19"]);
                        tb.CHourValue20 = Convert.ToDecimal(dataReader["20"]);
                        tb.CHourValue21 = Convert.ToDecimal(dataReader["21"]);
                        tb.CHourValue22 = Convert.ToDecimal(dataReader["22"]);
                        tb.CHourValue23 = Convert.ToDecimal(dataReader["23"]);
                        tb.CHourValue24 = Convert.ToDecimal(dataReader["24"]);
                        tbAll.Add(tb);
                    }
                }
            }
            return tbAll;
        }
    }
}
